home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / deletepool.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-12  |  1.8 KB  |  85 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: deletepool.c,v 1.4 1996/08/13 13:56:00 digulla Exp $
  4.     $Log: deletepool.c,v $
  5.     Revision 1.4  1996/08/13 13:56:00  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.3  1996/08/01 17:41:09  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang:
  15. */
  16. #include "exec_intern.h"
  17. #include <aros/libcall.h>
  18. #include "machine.h"
  19. #include "memory.h"
  20.  
  21. /*****************************************************************************
  22.  
  23.     NAME */
  24.     #include <exec/memory.h>
  25.     #include <clib/exec_protos.h>
  26.  
  27.     __AROS_LH1(void, DeletePool,
  28.  
  29. /*  SYNOPSIS */
  30.     __AROS_LHA(APTR, poolHeader, A0),
  31.  
  32. /*  LOCATION */
  33.     struct ExecBase *, SysBase, 117, Exec)
  34.  
  35. /*  FUNCTION
  36.     Delete a pool including all it's memory.
  37.  
  38.     INPUTS
  39.     poolHeader - The pool allocated with CreatePool() or NULL.
  40.  
  41.     RESULT
  42.  
  43.     NOTES
  44.  
  45.     EXAMPLE
  46.  
  47.     BUGS
  48.  
  49.     SEE ALSO
  50.     CreatePool(), AllocPooled(), FreePooled()
  51.  
  52.     INTERNALS
  53.  
  54.     HISTORY
  55.     16-10-95    created by m. fleischer
  56.  
  57. ******************************************************************************/
  58. {
  59.     __AROS_FUNC_INIT
  60.  
  61.     struct Pool *pool=(struct Pool *)poolHeader;
  62.  
  63.     /* It is legal to DeletePool(NULL) */
  64.     if(pool!=NULL)
  65.     {
  66.     void *p;
  67.     struct Block *bl;
  68.     ULONG size;
  69.  
  70.     /* Calculate the total size of a puddle including header. */
  71.     size=pool->PuddleSize+MEMHEADER_TOTAL;
  72.     /* Free the list of puddles */
  73.     while((p=RemHead((struct List *)&pool->PuddleList))!=NULL)
  74.         FreeMem(p,size);
  75.  
  76.     /* Free the list of single Blocks */
  77.     while((bl=(struct Block *)RemHead((struct List *)&pool->BlockList))!=NULL)
  78.         FreeMem(bl,bl->Size);
  79.  
  80.     FreeMem(pool,sizeof(struct Pool));
  81.     }
  82.     __AROS_FUNC_EXIT
  83. } /* DeletePool */
  84.  
  85.